#!/php -q
<?php  

/*
*	The MIT License
*
*	Copyright (c) 2010 Andrew Tutt
*
*	Permission is hereby granted, free of charge, to any person obtaining a copy
*	of this software and associated documentation files (the "Software"), to deal
*	in the Software without restriction, including without limitation the rights
*	to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
*	copies of the Software, and to permit persons to whom the Software is
*	furnished to do so, subject to the following conditions:
*
*	The above copyright notice and this permission notice shall be included in
*	all copies or substantial portions of the Software.
*
*	THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
*	IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
*	FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
*	AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
*	LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
*	OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
*	THE SOFTWARE.
*
*/

/* 
	This has been tested and works with Apache 2.2 and PHP5 installed
	on windows XP
 
	Run from command line:
	> php -q run.php

 */

date_default_timezone_set('EST');

require_once "kushtVars.inc";
require_once "phpUtilities.inc";
require_once "strPackager.class.inc";

require_once "Network/BasicServer.class.inc";
require_once "Network/BasicConnector.class.inc";
require_once "Network/ioHandler.class.inc";

require_once "Game/World.class.inc";
require_once "Game/Room.class.inc";
require_once "Game/Exit_.class.inc";
require_once "Game/Character.class.inc";
require_once "Game/UserCharacter.class.inc";
require_once "Game/Item.class.inc";
require_once "Game/Affect.class.inc";
require_once "Game/BasicStructs.inc";

require_once "Database/dbHandler.class.inc";

require_once "cmdHandler.class.inc";
require_once "flagHandler.class.inc";
require_once "clientHandler.class.inc";
require_once "loginHandler.class.inc";

// The Database Might Need to Save the whole world-state on shutdown
ini_set('max_execution_time', 300); //300 seconds = 5 minutes

// Load the Game (This will eventually be done in "Game" Engine Instantiation
dbHandler::connect("localhost:3306","kusht","kusht");
dbHandler::loadGame();

$server = new BasicServer("localhost",12345);

while(true) {
	$server->handle_connections();
	World::Update();
	usleep(10000);
}

?>